package com.noble.glamour.bean.center.user.detail;

import android.os.Parcel;
import android.text.TextUtils;

import org.json.JSONObject;

/**
 * 用户基本信息
 */
public class UserInfo extends UserBasic {
    private String avatarBig;
    private int avatar_status;   // 头像状态 0为未审核，1为通过，2为拒绝,3未上传 4 好 5 很好
    private boolean isVip;
    private long vipStartTime; // vip开始时间
    private long vipEndTime;
    private int diamand;            // 我的钻石


    // 以下暂时保留
    private boolean isOnline;       // 是否在线
    private int idcard_validation;  // 身份证验证状态  0 未提交 1 待审核 2 审核通过 3 审核不通过
    private String shareCode;       // 邀请码
    private boolean miss_info;      // 资料是否完整
    private int videoAuth;          // 用户视频权限
    private int validation_status;  // 用户认证状态  1 通过 0 未通过
    private int followmecount;      // 关注数
    private int inbellegroup;       //是否加入公会    1 加入 0未加入

    // --------------- 自己字段 -----------------------
    private String complete;        // 资料完整度(%)
    private double redbagsum;       // 红包总额
    private String reasons;         // 头像被拒原因
    private String cell_phone;      // 认证绑定的手机号
    private int giftfriendscnt;     // 赠礼好友数量
    private int channel_uid;        // 用户来源主渠道id
    private int channel_sid;        // 用户来源子渠道id
    private double todayEarnMoney;  // 女性：每日收益(单位：分)

    // --------------- TA人字段 ------------------------
    private int kf_id;
    private String distance;           // 距离
    private int isfollow;           // 是否已关注该用户
    private String online_text;     // 在线时间 "七天前在线"
    private boolean isSayHello;     // 是否已打招呼
    private String remark;          // 备注名

    public void parseBasic(String s) {
        super.parseJson(s);
    }

    @Override
    public void parseJson(String s) {
        JSONObject detailObject = getJsonObject(s);
        this.setUid(detailObject.optLong("Id"));
        this.setAvatarBig(detailObject.optString("AvatarBig"));
        this.setAvatar_status(detailObject.optInt("AvatarStatus"));
        this.setVip(detailObject.optBoolean("Isvip"));
        this.setVipStartTime(detailObject.optLong("VipStartTime"));
        this.setVipEndTime(detailObject.optLong("VipEndTime"));
        this.setDiamand(detailObject.optInt("Diamond"));


        // 以下暂时保留
        this.setComplete(detailObject.optString("complete"));
        this.setCell_phone(detailObject.optString("cell_phone"));
        this.setChannel_uid(detailObject.optInt("channel_uid"));
        this.setChannel_sid(detailObject.optInt("channel_sid"));
        this.setDistance(detailObject.optString("distance"));
        this.setFollowmecount(detailObject.optInt("followmecount"));
        this.setGiftfriendscnt(detailObject.optInt("giftfriendscnt"));
        this.setOnline(detailObject.optBoolean("is_online"));
        this.setIdcard_validation(detailObject.optInt("idcard_validation"));
        this.setIsfollow(detailObject.optInt("is_follow"));
        this.setSayHello(detailObject.optBoolean("isSayHello"));
        inbellegroup = detailObject.optInt("inbellegroup");
        this.setKf_id(detailObject.optInt("kf_id"));
        this.setMiss_info(detailObject.optBoolean("miss_info"));
        this.setOnline_text(detailObject.optString("online_text"));
        this.setRedbagsum(detailObject.optDouble("redbagsum"));
        this.setReasons(detailObject.optString("reasons"));
        this.setRemark(detailObject.optString("remark"));
        this.setShareCode(detailObject.optString("shareCode"));
        this.setTodayEarnMoney(detailObject.optDouble("todayestimateearnings"));
        this.setVideoAuth(detailObject.optInt("video_auth"));
        this.setValidation_status(detailObject.optInt("validation_status"));
    }

    public long getVipEndTime() {
        return vipEndTime;
    }

    public void setVipEndTime(long vipEndTime) {
        this.vipEndTime = vipEndTime;
    }

    public long getVipStartTime() {
        return vipStartTime;
    }

    public void setVipStartTime(long vipStartTime) {
        this.vipStartTime = vipStartTime;
    }

    public int getAvatar_status() {
        return avatar_status;
    }

    public void setAvatar_status(int avatar_status) {
        this.avatar_status = avatar_status;
    }

    public String getAvatarBig() {
        return avatarBig;
    }

    public void setAvatarBig(String avatarBig) {
        this.avatarBig = avatarBig;
    }

    /**
     * 是否通过全部认证
     */
    public boolean isVerifyAll() {
        return validation_status == 1;
    }

    /**
     * 是否加入公会
     *
     * @return
     */
    public boolean isJoinGuild() {
        return inbellegroup == 1;
    }

    /**
     * 设置是否加入公会
     *
     * @param isJoin
     */
    public void setJoinGuild(boolean isJoin) {
        inbellegroup = isJoin ? 1 : 0;
    }

    /**
     * 是否通过真人认证
     */
    public boolean isVerifyIdcard() {
        return idcard_validation == 2;
    }

    /**
     * 判断是否是vip
     */
    public boolean isVip() {
        return isVip;
    }

    public void setVip(boolean vip) {
        isVip = vip;
    }

    /**
     * 是否绑定手机
     */
    public boolean isVerifyCellphone() {
        return !TextUtils.isEmpty(cell_phone);
    }

    /**
     * 是否已关注
     */
    public boolean isFollow() {
        return isfollow != 0;
    }

    /**
     * 是否已打招呼
     */
    public boolean isSayHello() {
        return isSayHello;
    }

    public void setGroup(int group) {
    }

    public void setSayHello(boolean sayHello) {
        isSayHello = sayHello;
    }

    public int getGiftfriendscnt() {
        return giftfriendscnt;
    }

    public void setGiftfriendscnt(int giftfriendscnt) {
        this.giftfriendscnt = giftfriendscnt;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public void setValidation_status(int validation_status) {
        this.validation_status = validation_status;
    }

    public boolean isMiss_info() {
        return miss_info;
    }

    public void setMiss_info(boolean miss_info) {
        this.miss_info = miss_info;
    }

    public String getReasons() {
        return reasons;
    }

    public void setReasons(String reasons) {
        this.reasons = reasons;
    }

    public String getCell_phone() {
        return cell_phone;
    }

    public void setCell_phone(String cell_phone) {
        this.cell_phone = cell_phone;
    }

    public int getKf_id() {
        return kf_id;
    }

    public void setKf_id(int kf_id) {
        this.kf_id = kf_id;
    }

    public String getOnline_text() {
        return online_text;
    }

    public void setOnline_text(String online_text) {
        this.online_text = online_text;
    }

    public void setIsfollow(int isfollow) {
        this.isfollow = isfollow;
    }

    public int getFollowmecount() {
        return followmecount;
    }

    public void setFollowmecount(int followmecount) {
        this.followmecount = followmecount;
    }

    public String getDistance() {
        return distance;
    }

    public void setDistance(String distance) {
        this.distance = distance;
    }

    public int getIdcard_validation() {
        return idcard_validation;
    }

    public void setIdcard_validation(int idcard_validation) {
        this.idcard_validation = idcard_validation;
    }

    public int getVideoAuth() {
        return videoAuth;
    }

    public void setVideoAuth(int videoAuth) {
        this.videoAuth = videoAuth;
    }

    public int getDiamand() {
        return diamand;
    }

    public void setDiamand(int diamand) {
        this.diamand = diamand;
    }

    public double getRedbagsum() {
        return redbagsum;
    }

    public void setRedbagsum(double redbagsum) {
        this.redbagsum = redbagsum;
    }

    public String getComplete() {
        return complete;
    }

    public void setComplete(String complete) {
        this.complete = complete;
    }

    public boolean isOnline() {
        return isOnline;
    }

    public void setOnline(boolean online) {
        isOnline = online;
    }

    public String getShareCode() {
        return shareCode;
    }

    public void setShareCode(String shareCode) {
        this.shareCode = shareCode;
    }

    public int getChannel_uid() {
        return channel_uid;
    }

    public void setChannel_uid(int channel_uid) {
        this.channel_uid = channel_uid;
    }

    public int getChannel_sid() {
        return channel_sid;
    }

    public void setChannel_sid(int channel_sid) {
        this.channel_sid = channel_sid;
    }

    public double getTodayEarnMoney() {
        return todayEarnMoney;
    }

    public void setTodayEarnMoney(double todayEarnMoney) {
        this.todayEarnMoney = todayEarnMoney;
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(this.uid);
        dest.writeInt(this.avatar_status);
        dest.writeByte(this.isOnline ? (byte) 1 : (byte) 0);
        dest.writeInt(this.idcard_validation);
        dest.writeString(this.shareCode);
        dest.writeByte(this.miss_info ? (byte) 1 : (byte) 0);
        dest.writeInt(this.videoAuth);
        dest.writeInt(this.validation_status);
        dest.writeInt(this.followmecount);
        dest.writeInt(this.inbellegroup);
        dest.writeString(this.complete);
        dest.writeDouble(this.redbagsum);
        dest.writeString(this.reasons);
        dest.writeInt(this.diamand);
        dest.writeString(this.cell_phone);
        dest.writeInt(this.giftfriendscnt);
        dest.writeInt(this.channel_uid);
        dest.writeInt(this.channel_sid);
        dest.writeDouble(this.todayEarnMoney);
        dest.writeInt(this.kf_id);
        dest.writeString(this.distance);
        dest.writeInt(this.isfollow);
        dest.writeString(this.online_text);
        dest.writeByte(this.isSayHello ? (byte) 1 : (byte) 0);
        dest.writeString(this.remark);
    }

    public UserInfo() {
    }

    protected UserInfo(Parcel in) {
        this.uid = in.readLong();
        this.avatar_status = in.readInt();
        this.isOnline = in.readByte() != 0;
        this.idcard_validation = in.readInt();
        this.shareCode = in.readString();
        this.miss_info = in.readByte() != 0;
        this.videoAuth = in.readInt();
        this.validation_status = in.readInt();
        this.followmecount = in.readInt();
        this.inbellegroup = in.readInt();
        this.complete = in.readString();
        this.redbagsum = in.readDouble();
        this.reasons = in.readString();
        this.diamand = in.readInt();
        this.cell_phone = in.readString();
        this.giftfriendscnt = in.readInt();
        this.channel_uid = in.readInt();
        this.channel_sid = in.readInt();
        this.todayEarnMoney = in.readDouble();
        this.kf_id = in.readInt();
        this.distance = in.readString();
        this.isfollow = in.readInt();
        this.online_text = in.readString();
        this.isSayHello = in.readByte() != 0;
        this.remark = in.readString();
    }

    public static final Creator<UserInfo> CREATOR = new Creator<UserInfo>() {
        @Override
        public UserInfo createFromParcel(Parcel source) {
            return new UserInfo(source);
        }

        @Override
        public UserInfo[] newArray(int size) {
            return new UserInfo[size];
        }
    };
}
